/**
 * Created by wangfei on 2017/7/3.
 */
/**
 *
 *  @auth xlx_good@qq.com
 *  @date 17/6/21.
 *
 */

requirejs.config({
    baseUrl: '../../',
    paths:  {
        avalon: 'javascript/avalon.min',
        jquery: 'js/plugins/jquery/jquery-2.1.1.min',
        config: 'javascript/config',
        api: 'javascript/api',
        layer: 'js/plugins/layer1/layer',
        arg: 'javascript/arg'
    },
    shim: {
        api: {
            deps: ['jquery']
        },
        layer: {
            deps: ['jquery']
        }
    }
});


(function(win, dom, requirejs, initVm){
    var vm;
    requirejs(['avalon', 'jquery', 'config' ,'api', 'layer','arg'], function(){
        //初始化vm
        vm = initVm(dom);
    });


})(window, document, requirejs, function(dom){
    var vm = avalon.define({
        $id:'container',
        paramsCode:{},
        params: {
            orderSub: {
                siteName: '',
                supplierName: '',
                code: '',
                statusOrder: '',
                buyerUserName: '',
                orderTime: '',
                amountTotalSub: '',
                addressName: '',
				contacts: '',
				phone: ''
            },
            orderMain: {
                batch: '',
                payTime: '',
                payMethodName: '',
                invoiceType: '',
                invoiceTitle: '',
                invoiceContent: '',
                taxpayerCode: '',
                regAddress: '',
                regPhone: '',
                bank: '',
                bankAccount: '',
				description: ''
            },
            orderWares: [{
                wareId: '',
                wareName: '',
                barcode: '',
                numberPerBox: '',
                pricePiece: '',
                number: '',
                amountTotal:''
            }]
        },
		invoiceTypeName: '',
        //订单详情
        orderDetail: function(code) {
            Api.orderGet({code: code} ,function(resp) {
                if(resp.code == 0) {
                    vm.params  = resp.data;
					vm.invoiceTypeName = invoiceTypeMap[vm.params.orderMain.invoiceType];
					vm.params.orderMain.description = vm.params.orderMain.description == null ? '' : vm.params.orderMain.description;
                } else {
                    layer.msg(resp.msg);
                }
            })
        }
    });
    vm.paramsCode = Arg.parse(location.href);
    if(vm.paramsCode.code) {
        vm.orderDetail(vm.paramsCode.code);
    }
    avalon.scan(dom.body);
    return vm;
});



